package net.lastcoder.ifserver.util;

/**
 * auth: WenYF
 * date: 2017/1/12
 */
public class QuickCrypter {
    public static void encrypt(byte[] data, int key) {
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) (data[i] ^ key);
        }
    }

    public static void encrypt(byte[] data, int start, int offset, int key) {
        for (int i = start; i < offset + start; i++) {
            data[i] = (byte) (data[i] ^ key);
        }
    }

    public static void decrypt(byte[] data, int key) {
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) (data[i] ^ key);
        }
    }

    public static void decrypt(byte[] data, int start, int offset, int key) {
        for (int i = start; i < offset + start; i++) {
            data[i] = (byte) (data[i] ^ key);
        }
    }


    public static void encrypt(byte[] data) {
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) (data[i] ^ 0x11);
        }
    }

    public static void encrypt(byte[] data, int start, int offset) {
        for (int i = start; i < offset + start; i++) {
            data[i] = (byte) (data[i] ^ 0x11);
        }
    }

    public static void decrypt(byte[] data) {
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) (data[i] ^ 0x11);
        }
    }

    public static void decrypt(byte[] data, int start, int offset) {
        for (int i = start; i < offset + start; i++) {
            data[i] = (byte) (data[i] ^ 0x11);
        }
    }
}